<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCouponTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupon', function (Blueprint $table) {
            $table->integerIncrements('id');
            $table->string('name', 50)->comment('优惠券名称');
            $table->tinyInteger('type', false, true)->default(1)->comment('优惠方式 1-比例折扣 2-现金');
            $table->tinyInteger('coupon_value', false, true)->comment('优惠价格 折扣/元');
            $table->tinyInteger('validity_day', false, true)->default(0)->comment('有效期 单位天 0-长期有效');
            $table->string('use_time_start')->default(0)->comment('开始使用时段');
            $table->string('use_time_end')->default(0)->comment('结束使用时段');
            $table->tinyInteger('use_full', false, true)->default(0)->comment('使用条件 满多少可使用 单位元');
            $table->tinyInteger('status', false, true)->default(1)->comment('状态 0禁用 1-正常');

            $table->timestamps();
            $table->softDeletes();
        });
        \DB::statement("ALTER TABLE `coupon` comment '优惠券'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupon');
    }
}
